#! /bin/bash
# Copyright Huawei Technologies Co., Ltd. 2022-2023. All rights reserved.
# 视频流云手机启动脚本配置文件，可配置云手机绑定的GPU、CPU、NUMA、编码卡、数据卷存放位置等

# 默认镜像名称，可根据需要自行修改
DOCKER_IMAGE=video:latest

# 云手机运行内存
RAM_SIZE_GB=6
# 云手机存储大小
STORAGE_SIZE_GB=16

# 云手机屏幕宽、高、密度三者要匹配，720p(720 1280 320)，1080p(1080 1920 480)
# 云手机屏幕宽度
BUILD_WIDTH=720
# 云手机屏幕高度
BUILD_HEIGHT=1280
# 云手机屏幕密度
BUILD_DENSITY=320
# 云手机屏幕刷新帧率
BUILD_FPS=30

# 云手机绑核方式 0：2容器2核(默认)；1：绑NUMA，每NUMA空前2个核
CPU_BIND_MODE=0

# GPU设备节点(最多有4 * 10 = 40个渲染节点)
GPUS=(
    "/dev/dri/renderD128" "/dev/dri/renderD129" "/dev/dri/renderD130" "/dev/dri/renderD131"
    "/dev/dri/renderD132" "/dev/dri/renderD133" "/dev/dri/renderD134" "/dev/dri/renderD135"
    "/dev/dri/renderD136" "/dev/dri/renderD137" "/dev/dri/renderD138" "/dev/dri/renderD139"
    "/dev/dri/renderD140" "/dev/dri/renderD141" "/dev/dri/renderD142" "/dev/dri/renderD143"
    "/dev/dri/renderD144" "/dev/dri/renderD145" "/dev/dri/renderD146" "/dev/dri/renderD147"
    "/dev/dri/renderD148" "/dev/dri/renderD149" "/dev/dri/renderD150" "/dev/dri/renderD151"
    "/dev/dri/renderD152" "/dev/dri/renderD153" "/dev/dri/renderD154" "/dev/dri/renderD155"
    "/dev/dri/renderD156" "/dev/dri/renderD157" "/dev/dri/renderD158" "/dev/dri/renderD159"
    "/dev/dri/renderD160" "/dev/dri/renderD161" "/dev/dri/renderD162" "/dev/dri/renderD163"
    "/dev/dri/renderD164" "/dev/dri/renderD165" "/dev/dri/renderD166" "/dev/dri/renderD167"
)

# VPU设备节点(XD 最多有6 * 6 = 36个vpu节点)
VPUS=(
    "/dev/vpu0" "/dev/vpu1" "/dev/vpu2" "/dev/vpu3" "/dev/vpu4" "/dev/vpu5"
    "/dev/vpu6" "/dev/vpu7" "/dev/vpu8" "/dev/vpu9" "/dev/vpu10" "/dev/vpu11"
    "/dev/vpu12" "/dev/vpu13" "/dev/vpu14" "/dev/vpu15" "/dev/vpu16" "/dev/vpu17"
    "/dev/vpu18" "/dev/vpu19" "/dev/vpu20" "/dev/vpu21" "/dev/vpu22" "/dev/vpu23"
    "/dev/vpu24" "/dev/vpu25" "/dev/vpu26" "/dev/vpu27" "/dev/vpu28" "/dev/vpu29"
    "/dev/vpu30" "/dev/vpu31" "/dev/vpu32" "/dev/vpu33" "/dev/vpu34" "/dev/vpu35"
)

# 选择编码卡（0:T432 1:Quadra 2:Va1e 3:open264）
ENCODECARD=1

# T432/Quadra硬解使能开关, 1表示使能，其他值默认不使能
T432_QUADRA_DECODE_ENABLE=0

# NETINT编码卡设备节点
NETINT0="/dev/nvme0,/dev/nvme0n1,/dev/nvme1,/dev/nvme1n1"
NETINT1="/dev/nvme0,/dev/nvme0n1,/dev/nvme1,/dev/nvme1n1"

#DC1000硬解使能开关, 1表示使能，其他值默认不使能
ENABLE_HARD_DECODE=1

#webrtc使能开关, 1表示使能，其他值默认不使能
ENABLE_WEBRTC_CONNECTION=0

#渲染中间层开关，1表示使能，其他值默认不使能
ENABLE_RENDER_LAYER=0

#软渲染开关，1表示使能，其他值默认不使能
ENABLE_SOFT_RENDER=0

#是否使能纯64位，1表示使能，其他值默认不使能
ENABLE_ONLY64_KBOX=0

# VASTAI编码卡设备节点
HANBO_ENCODERS=(
    "0.0"
    "0.1"
    "1.0"
    "1.1"
)

# 数据卷存放位置
USERDATA="/home/mount"

# 320核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中仅绑定NUMA的方式
MODE0_CPUS0_320=("2,3" "4,5" "6,7" "8,9" "10,11" "12,13" "14,15" "16,17" "18,19" "20,21" "22,23" "24,25" "26,27" "28,29" "30,31" "32,33" "34,35" "36,37" "38,39" "40,41" "42,43" "44,45" "46,47" "48,49" "50,51" "52,53" "54,55" "56,57" "58,59" "60,61" "62,63" "64,65" "66,67" "68,69" "70,71" "72,73" "74,75" "76,77" "78,79")
MODE0_CPUS1_320=("82,83" "84,85" "86,87" "88,89" "90,91" "92,93" "94,95" "96,97" "98,99" "100,101" "102,103" "104,105" "106,107" "108,109" "110,111" "112,113" "114,115" "116,117" "118,119" "120,121" "122,123" "124,125" "126,127" "128,129" "130,131" "132,133" "134,135" "136,137" "138,139" "140,141" "142,143" "144,145" "146,147" "148,149" "150,151" "152,153" "154,155" "156,157" "158,159")
MODE0_CPUS2_320=("162,163" "164,165" "166,167" "168,169" "170,171" "172,173" "174,175" "176,177" "178,179" "180,181" "182,183" "184,185" "186,187" "188,189" "190,191" "192,193" "194,195" "196,197" "198,199" "200,201" "202,203" "204,205" "206,207" "208,209" "210,211" "212,213" "214,215" "216,217" "218,219" "220,221" "222,223" "224,225" "226,227" "228,229" "230,231" "232,233" "234,235" "236,237" "238,239")
MODE0_CPUS3_320=("242,243" "244,245" "246,247" "248,249" "250,251" "252,253" "254,255" "256,257" "258,259" "260,261" "262,263" "264,265" "266,267" "268,269" "270,271" "272,273" "274,275" "276,277" "278,279" "280,281" "282,283" "284,285" "286,287" "288,289" "290,291" "292,293" "294,295" "296,297" "298,299" "300,301" "302,303" "304,305" "306,307" "308,309" "310,311" "312,313" "314,315" "316,317" "318,319")

# 320核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中仅绑定NUMA的方式
# numa0空前8核，其余numa空前4核；每个numa前4核用于显卡驱动kworker绑核；numa0的4-7空闲，用于解决unity挤占容器内前4核资源的问题。
MODE1_CPUS0_320="8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79"
MODE1_CPUS1_320="84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159"
MODE1_CPUS2_320="164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239"
MODE1_CPUS3_320="244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319"

# 160核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中2容器2核的方式
MODE0_CPUS0_160=("2,3" "4,5" "6,7" "8,9" "10,11" "12,13" "14,15" "16,17" "18,19" "20,21" "22,23" "24,25" "26,27" "28,29" "30,31" "32,33" "34,35" "36,37" "38,39")
MODE0_CPUS1_160=("42,43" "44,45" "46,47" "48,49" "50,51" "52,53" "54,55" "56,57" "58,59" "60,61" "62,63" "64,65" "66,67" "68,69" "70,71" "72,73" "74,75" "76,77" "78,79")
MODE0_CPUS2_160=("82,83" "84,85" "86,87" "88,89" "90,91" "92,93" "94,95" "96,97" "98,99" "100,101" "102,103" "104,105" "106,107" "108,109" "110,111" "112,113" "114,115" "116,117" "118,119")
MODE0_CPUS3_160=("122,123" "124,125" "126,127" "128,129" "130,131" "132,133" "134,135" "136,137" "138,139" "140,141" "142,143" "144,145" "146,147" "148,149" "150,151" "152,153" "154,155" "156,157" "158,159")

# 160核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中仅绑定NUMA的方式
MODE1_CPUS0_160="2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39"
MODE1_CPUS1_160="42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79"
MODE1_CPUS2_160="82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119"
MODE1_CPUS3_160="122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159"

# 128核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中2容器2核的方式
MODE0_CPUS0=("2,3" "4,5" "6,7" "8,9" "10,11" "12,13" "14,15" "16,17" "18,19" "20,21" "22,23" "24,25" "26,27" "28,29" "30,31")
MODE0_CPUS1=("34,35" "36,37" "38,39" "40,41" "42,43" "44,45" "46,47" "48,49" "50,51" "52,53" "54,55" "56,57" "58,59" "60,61" "62,63")
MODE0_CPUS2=("66,67" "68,69" "70,71" "72,73" "74,75" "76,77" "78,79" "80,81" "82,83" "84,85" "86,87" "88,89" "90,91" "92,93" "94,95")
MODE0_CPUS3=("98,99" "100,101" "102,103" "104,105" "106,107" "108,109" "110,111" "112,113" "114,115" "116,117" "118,119" "120,121" "122,123" "124,125" "126,127")

# 128核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中仅绑定NUMA的方式
MODE1_CPUS0="2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31"
MODE1_CPUS1="34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63"
MODE1_CPUS2="66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95"
MODE1_CPUS3="98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127"

# 128核2NUMA情况下，各NUMA平分后CPU核定义，用于XD云手机绑核策略中仅绑定NUMA的方式
MODE1_2NUMA_CPUS0="8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63"
MODE1_2NUMA_CPUS1="72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127"

# 96核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中2容器2核的方式
MODE0_CPUS0_96=("2,3" "4,5" "6,7" "8,9" "10,11" "12,13" "14,15" "16,17" "18,19" "20,21" "22,23")
MODE0_CPUS1_96=("26,27" "28,29" "30,31" "34,35" "36,37" "38,39" "40,41" "42,43" "44,45" "46,47")
MODE0_CPUS2_96=("50,51" "52,53" "54,55" "56,57" "58,59" "60,61" "62,63" "66,67" "68,69" "70,71")
MODE0_CPUS3_96=("74,75" "76,77" "78,79" "80,81" "82,83" "84,85" "86,87" "88,89" "90,91" "92,93" "94,95")

# 96核4NUMA情况下，各NUMA内CPU核定义，用于云手机绑核策略中仅绑定NUMA的方式
MODE1_CPUS0_96="2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23"
MODE1_CPUS1_96="26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47"
MODE1_CPUS2_96="50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71"
MODE1_CPUS3_96="74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95"

# Vsync信号偏移量定义，用于Vsync信号均衡优化
VSYNC_OFFSET0="0"
VSYNC_OFFSET1="16000000"
VSYNC_OFFSET2="8000000"
VSYNC_OFFSET3="24000000"

VIDEO_CPU_MAP_320CORE_MODE0=(
    "${MODE0_CPUS0_320[0]}"
    "${MODE0_CPUS2_320[0]}"
    "${MODE0_CPUS1_320[0]}"
    "${MODE0_CPUS3_320[0]}"
    "${MODE0_CPUS0_320[1]}"
    "${MODE0_CPUS2_320[1]}"
    "${MODE0_CPUS1_320[1]}"
    "${MODE0_CPUS3_320[1]}"
    "${MODE0_CPUS0_320[2]}"
    "${MODE0_CPUS2_320[2]}"
    "${MODE0_CPUS1_320[2]}"
    "${MODE0_CPUS3_320[2]}"
    "${MODE0_CPUS0_320[3]}"
    "${MODE0_CPUS2_320[3]}"
    "${MODE0_CPUS1_320[3]}"
    "${MODE0_CPUS3_320[3]}"
    "${MODE0_CPUS0_320[4]}"
    "${MODE0_CPUS2_320[4]}"
    "${MODE0_CPUS1_320[4]}"
    "${MODE0_CPUS3_320[4]}"
    "${MODE0_CPUS0_320[5]}"
    "${MODE0_CPUS2_320[5]}"
    "${MODE0_CPUS1_320[5]}"
    "${MODE0_CPUS3_320[5]}"
    "${MODE0_CPUS0_320[6]}"
    "${MODE0_CPUS2_320[6]}"
    "${MODE0_CPUS1_320[6]}"
    "${MODE0_CPUS3_320[6]}"
    "${MODE0_CPUS0_320[7]}"
    "${MODE0_CPUS2_320[7]}"
    "${MODE0_CPUS1_320[7]}"
    "${MODE0_CPUS3_320[7]}"
    "${MODE0_CPUS0_320[8]}"
    "${MODE0_CPUS2_320[8]}"
    "${MODE0_CPUS1_320[8]}"
    "${MODE0_CPUS3_320[8]}"
    "${MODE0_CPUS0_320[9]}"
    "${MODE0_CPUS2_320[9]}"
    "${MODE0_CPUS1_320[9]}"
    "${MODE0_CPUS3_320[9]}"
    "${MODE0_CPUS0_320[10]}"
    "${MODE0_CPUS2_320[10]}"
    "${MODE0_CPUS1_320[10]}"
    "${MODE0_CPUS3_320[10]}"
    "${MODE0_CPUS0_320[11]}"
    "${MODE0_CPUS2_320[11]}"
    "${MODE0_CPUS1_320[11]}"
    "${MODE0_CPUS3_320[11]}"
    "${MODE0_CPUS0_320[12]}"
    "${MODE0_CPUS2_320[12]}"
    "${MODE0_CPUS1_320[12]}"
    "${MODE0_CPUS3_320[12]}"
    "${MODE0_CPUS0_320[13]}"
    "${MODE0_CPUS2_320[13]}"
    "${MODE0_CPUS1_320[13]}"
    "${MODE0_CPUS3_320[13]}"
    "${MODE0_CPUS0_320[14]}"
    "${MODE0_CPUS2_320[14]}"
    "${MODE0_CPUS1_320[14]}"
    "${MODE0_CPUS3_320[14]}"
    "${MODE0_CPUS0_320[15]}"
    "${MODE0_CPUS2_320[15]}"
    "${MODE0_CPUS1_320[15]}"
    "${MODE0_CPUS3_320[15]}"
    "${MODE0_CPUS0_320[16]}"
    "${MODE0_CPUS2_320[16]}"
    "${MODE0_CPUS1_320[16]}"
    "${MODE0_CPUS3_320[16]}"
    "${MODE0_CPUS0_320[17]}"
    "${MODE0_CPUS2_320[17]}"
    "${MODE0_CPUS1_320[17]}"
    "${MODE0_CPUS3_320[17]}"
    "${MODE0_CPUS0_320[18]}"
    "${MODE0_CPUS2_320[18]}"
    "${MODE0_CPUS1_320[18]}"
    "${MODE0_CPUS3_320[18]}"
    "${MODE0_CPUS0_320[19]}"
    "${MODE0_CPUS2_320[19]}"
    "${MODE0_CPUS1_320[19]}"
    "${MODE0_CPUS3_320[19]}"
    "${MODE0_CPUS0_320[20]}"
    "${MODE0_CPUS2_320[20]}"
    "${MODE0_CPUS1_320[20]}"
    "${MODE0_CPUS3_320[20]}"
    "${MODE0_CPUS0_320[21]}"
    "${MODE0_CPUS2_320[21]}"
    "${MODE0_CPUS1_320[21]}"
    "${MODE0_CPUS3_320[21]}"
    "${MODE0_CPUS0_320[22]}"
    "${MODE0_CPUS2_320[22]}"
    "${MODE0_CPUS1_320[22]}"
    "${MODE0_CPUS3_320[22]}"
    "${MODE0_CPUS0_320[23]}"
    "${MODE0_CPUS2_320[23]}"
    "${MODE0_CPUS1_320[23]}"
    "${MODE0_CPUS3_320[23]}"
    "${MODE0_CPUS0_320[24]}"
    "${MODE0_CPUS2_320[24]}"
    "${MODE0_CPUS1_320[24]}"
    "${MODE0_CPUS3_320[24]}"
    "${MODE0_CPUS0_320[25]}"
    "${MODE0_CPUS2_320[25]}"
    "${MODE0_CPUS1_320[25]}"
    "${MODE0_CPUS3_320[25]}"
    "${MODE0_CPUS0_320[26]}"
    "${MODE0_CPUS2_320[26]}"
    "${MODE0_CPUS1_320[26]}"
    "${MODE0_CPUS3_320[26]}"
    "${MODE0_CPUS0_320[27]}"
    "${MODE0_CPUS2_320[27]}"
    "${MODE0_CPUS1_320[27]}"
    "${MODE0_CPUS3_320[27]}"
    "${MODE0_CPUS0_320[28]}"
    "${MODE0_CPUS2_320[28]}"
    "${MODE0_CPUS1_320[28]}"
    "${MODE0_CPUS3_320[28]}"
    "${MODE0_CPUS0_320[29]}"
    "${MODE0_CPUS2_320[29]}"
    "${MODE0_CPUS1_320[29]}"
    "${MODE0_CPUS3_320[29]}"
    "${MODE0_CPUS0_320[30]}"
    "${MODE0_CPUS2_320[30]}"
    "${MODE0_CPUS1_320[30]}"
    "${MODE0_CPUS3_320[30]}"
    "${MODE0_CPUS0_320[31]}"
    "${MODE0_CPUS2_320[31]}"
    "${MODE0_CPUS1_320[31]}"
    "${MODE0_CPUS3_320[31]}"
    "${MODE0_CPUS0_320[32]}"
    "${MODE0_CPUS2_320[32]}"
    "${MODE0_CPUS1_320[32]}"
    "${MODE0_CPUS3_320[32]}"
    "${MODE0_CPUS0_320[33]}"
    "${MODE0_CPUS2_320[33]}"
    "${MODE0_CPUS1_320[33]}"
    "${MODE0_CPUS3_320[33]}"
    "${MODE0_CPUS0_320[34]}"
    "${MODE0_CPUS2_320[34]}"
    "${MODE0_CPUS1_320[34]}"
    "${MODE0_CPUS3_320[34]}"
    "${MODE0_CPUS0_320[35]}"
    "${MODE0_CPUS2_320[35]}"
    "${MODE0_CPUS1_320[35]}"
    "${MODE0_CPUS3_320[35]}"
    "${MODE0_CPUS0_320[36]}"
    "${MODE0_CPUS2_320[36]}"
    "${MODE0_CPUS1_320[36]}"
    "${MODE0_CPUS3_320[36]}"
    "${MODE0_CPUS0_320[37]}"
    "${MODE0_CPUS2_320[37]}"
    "${MODE0_CPUS1_320[37]}"
    "${MODE0_CPUS3_320[37]}"
    "${MODE0_CPUS0_320[38]}"
    "${MODE0_CPUS2_320[38]}"
    "${MODE0_CPUS1_320[38]}"
    "${MODE0_CPUS3_320[38]}"
)

VIDEO_CPU_MAP_320CORE_MODE1=(
    "${MODE1_CPUS0_320}"
    "${MODE1_CPUS2_320}"
    "${MODE1_CPUS1_320}"
    "${MODE1_CPUS3_320}"
)

VIDEO_CPU_MAP_160CORE_MODE0=(
    "${MODE0_CPUS0_160[0]}"
    "${MODE0_CPUS2_160[0]}"
    "${MODE0_CPUS1_160[0]}"
    "${MODE0_CPUS3_160[0]}"
    "${MODE0_CPUS0_160[1]}"
    "${MODE0_CPUS2_160[1]}"
    "${MODE0_CPUS1_160[1]}"
    "${MODE0_CPUS3_160[1]}"
    "${MODE0_CPUS0_160[2]}"
    "${MODE0_CPUS2_160[2]}"
    "${MODE0_CPUS1_160[2]}"
    "${MODE0_CPUS3_160[2]}"
    "${MODE0_CPUS0_160[3]}"
    "${MODE0_CPUS2_160[3]}"
    "${MODE0_CPUS1_160[3]}"
    "${MODE0_CPUS3_160[3]}"
    "${MODE0_CPUS0_160[4]}"
    "${MODE0_CPUS2_160[4]}"
    "${MODE0_CPUS1_160[4]}"
    "${MODE0_CPUS3_160[4]}"
    "${MODE0_CPUS0_160[5]}"
    "${MODE0_CPUS2_160[5]}"
    "${MODE0_CPUS1_160[5]}"
    "${MODE0_CPUS3_160[5]}"
    "${MODE0_CPUS0_160[6]}"
    "${MODE0_CPUS2_160[6]}"
    "${MODE0_CPUS1_160[6]}"
    "${MODE0_CPUS3_160[6]}"
    "${MODE0_CPUS0_160[7]}"
    "${MODE0_CPUS2_160[7]}"
    "${MODE0_CPUS1_160[7]}"
    "${MODE0_CPUS3_160[7]}"
    "${MODE0_CPUS0_160[8]}"
    "${MODE0_CPUS2_160[8]}"
    "${MODE0_CPUS1_160[8]}"
    "${MODE0_CPUS3_160[8]}"
    "${MODE0_CPUS0_160[9]}"
    "${MODE0_CPUS2_160[9]}"
    "${MODE0_CPUS1_160[9]}"
    "${MODE0_CPUS3_160[9]}"
    "${MODE0_CPUS0_160[10]}"
    "${MODE0_CPUS2_160[10]}"
    "${MODE0_CPUS1_160[10]}"
    "${MODE0_CPUS3_160[10]}"
    "${MODE0_CPUS0_160[11]}"
    "${MODE0_CPUS2_160[11]}"
    "${MODE0_CPUS1_160[11]}"
    "${MODE0_CPUS3_160[11]}"
    "${MODE0_CPUS0_160[12]}"
    "${MODE0_CPUS2_160[12]}"
    "${MODE0_CPUS1_160[12]}"
    "${MODE0_CPUS3_160[12]}"
    "${MODE0_CPUS0_160[13]}"
    "${MODE0_CPUS2_160[13]}"
    "${MODE0_CPUS1_160[13]}"
    "${MODE0_CPUS3_160[13]}"
    "${MODE0_CPUS0_160[14]}"
    "${MODE0_CPUS2_160[14]}"
    "${MODE0_CPUS1_160[14]}"
    "${MODE0_CPUS3_160[14]}"
    "${MODE0_CPUS0_160[15]}"
    "${MODE0_CPUS2_160[15]}"
    "${MODE0_CPUS1_160[15]}"
    "${MODE0_CPUS3_160[15]}"
    "${MODE0_CPUS0_160[16]}"
    "${MODE0_CPUS2_160[16]}"
    "${MODE0_CPUS1_160[16]}"
    "${MODE0_CPUS3_160[16]}"
    "${MODE0_CPUS0_160[17]}"
    "${MODE0_CPUS2_160[17]}"
    "${MODE0_CPUS1_160[17]}"
    "${MODE0_CPUS3_160[17]}"
    "${MODE0_CPUS0_160[18]}"
    "${MODE0_CPUS2_160[18]}"
    "${MODE0_CPUS1_160[18]}"
    "${MODE0_CPUS3_160[18]}"
)

VIDEO_CPU_MAP_160CORE_MODE1=(
    "${MODE1_CPUS0_160}"
    "${MODE1_CPUS2_160}"
    "${MODE1_CPUS1_160}"
    "${MODE1_CPUS3_160}"
)

VIDEO_CPU_MAP_128CORE_MODE0=(
    "${MODE0_CPUS0[0]}"
    "${MODE0_CPUS2[0]}"
    "${MODE0_CPUS1[0]}"
    "${MODE0_CPUS3[0]}"
    "${MODE0_CPUS0[1]}"
    "${MODE0_CPUS2[1]}"
    "${MODE0_CPUS1[1]}"
    "${MODE0_CPUS3[1]}"
    "${MODE0_CPUS0[2]}"
    "${MODE0_CPUS2[2]}"
    "${MODE0_CPUS1[2]}"
    "${MODE0_CPUS3[2]}"
    "${MODE0_CPUS0[3]}"
    "${MODE0_CPUS2[3]}"
    "${MODE0_CPUS1[3]}"
    "${MODE0_CPUS3[3]}"
    "${MODE0_CPUS0[4]}"
    "${MODE0_CPUS2[4]}"
    "${MODE0_CPUS1[4]}"
    "${MODE0_CPUS3[4]}"
    "${MODE0_CPUS0[5]}"
    "${MODE0_CPUS2[5]}"
    "${MODE0_CPUS1[5]}"
    "${MODE0_CPUS3[5]}"
    "${MODE0_CPUS0[6]}"
    "${MODE0_CPUS2[6]}"
    "${MODE0_CPUS1[6]}"
    "${MODE0_CPUS3[6]}"
    "${MODE0_CPUS0[7]}"
    "${MODE0_CPUS2[7]}"
    "${MODE0_CPUS1[7]}"
    "${MODE0_CPUS3[7]}"
    "${MODE0_CPUS0[8]}"
    "${MODE0_CPUS2[8]}"
    "${MODE0_CPUS1[8]}"
    "${MODE0_CPUS3[8]}"
    "${MODE0_CPUS0[9]}"
    "${MODE0_CPUS2[9]}"
    "${MODE0_CPUS1[9]}"
    "${MODE0_CPUS3[9]}"
    "${MODE0_CPUS0[10]}"
    "${MODE0_CPUS2[10]}"
    "${MODE0_CPUS1[10]}"
    "${MODE0_CPUS3[10]}"
    "${MODE0_CPUS0[11]}"
    "${MODE0_CPUS2[11]}"
    "${MODE0_CPUS1[11]}"
    "${MODE0_CPUS3[11]}"
    "${MODE0_CPUS0[12]}"
    "${MODE0_CPUS2[12]}"
    "${MODE0_CPUS1[12]}"
    "${MODE0_CPUS3[12]}"
    "${MODE0_CPUS0[13]}"
    "${MODE0_CPUS2[13]}"
    "${MODE0_CPUS1[13]}"
    "${MODE0_CPUS3[13]}"
    "${MODE0_CPUS0[14]}"
    "${MODE0_CPUS2[14]}"
    "${MODE0_CPUS1[14]}"
    "${MODE0_CPUS3[14]}"
)

VIDEO_CPU_MAP_128CORE_MODE1=(
    "${MODE1_CPUS0}"
    "${MODE1_CPUS2}"
    "${MODE1_CPUS1}"
    "${MODE1_CPUS3}"
)

# XD GPU内核驱动CPU占用较高，且亲和NUMA0和NUMA2，因此需要在NUMA间进行负载均衡
VIDEO_XD_CPU_MAP_128CORE_MODE1=(
    "${MODE1_2NUMA_CPUS0}"
    "${MODE1_2NUMA_CPUS1}"
)

# 920B/7265/7260(320/160/128/96核) AMD GPU 2张卡配置，对应2个设备节点，循环使用
VIDEO_GPU_MAP_AMD2=(
    "${GPUS[0]}"
    "${GPUS[1]}"
)

# 920B/7265/7260(320/160/128/96核) AMD GPU 1张卡配置，只要服务器上GPU数量不为2，均采用此配置，用户可自行在此配置中添加GPU设备节点
VIDEO_GPU_MAP_AMD1=(
    "${GPUS[0]}"
)

VIDEO_ENC_MAP_CORE=(
    "${NETINT0}"
    "${NETINT1}"
)

VIDEO_USERDATA_MAP_CORE=(
    "${USERDATA}"
)

VIDEO_VSYNC_OFFSET_MAP_AMD2=(
    "${VSYNC_OFFSET0}"
    "${VSYNC_OFFSET2}"
    "${VSYNC_OFFSET1}"
    "${VSYNC_OFFSET3}"
)

VIDEO_VSYNC_OFFSET_MAP_AMD1=(
    "${VSYNC_OFFSET0}"
    "${VSYNC_OFFSET1}"
)

VIDEO_CPU_MAP_96CORE_MODE0=(
    "${MODE0_CPUS0_96[0]}"
    "${MODE0_CPUS2_96[0]}"
    "${MODE0_CPUS1_96[0]}"
    "${MODE0_CPUS3_96[0]}"
    "${MODE0_CPUS0_96[1]}"
    "${MODE0_CPUS2_96[1]}"
    "${MODE0_CPUS1_96[1]}"
    "${MODE0_CPUS3_96[1]}"
    "${MODE0_CPUS0_96[2]}"
    "${MODE0_CPUS2_96[2]}"
    "${MODE0_CPUS1_96[2]}"
    "${MODE0_CPUS3_96[2]}"
    "${MODE0_CPUS0_96[3]}"
    "${MODE0_CPUS2_96[3]}"
    "${MODE0_CPUS1_96[3]}"
    "${MODE0_CPUS3_96[3]}"
    "${MODE0_CPUS0_96[4]}"
    "${MODE0_CPUS2_96[4]}"
    "${MODE0_CPUS1_96[4]}"
    "${MODE0_CPUS3_96[4]}"
    "${MODE0_CPUS0_96[5]}"
    "${MODE0_CPUS2_96[5]}"
    "${MODE0_CPUS1_96[5]}"
    "${MODE0_CPUS3_96[5]}"
    "${MODE0_CPUS0_96[6]}"
    "${MODE0_CPUS2_96[6]}"
    "${MODE0_CPUS1_96[6]}"
    "${MODE0_CPUS3_96[6]}"
    "${MODE0_CPUS0_96[7]}"
    "${MODE0_CPUS2_96[7]}"
    "${MODE0_CPUS1_96[7]}"
    "${MODE0_CPUS3_96[7]}"
    "${MODE0_CPUS0_96[8]}"
    "${MODE0_CPUS2_96[8]}"
    "${MODE0_CPUS1_96[8]}"
    "${MODE0_CPUS3_96[8]}"
    "${MODE0_CPUS0_96[9]}"
    "${MODE0_CPUS2_96[9]}"
    "${MODE0_CPUS1_96[9]}"
    "${MODE0_CPUS3_96[9]}"
    "${MODE0_CPUS0_96[10]}"
    "${MODE0_CPUS2_96[10]}"
    "${MODE0_CPUS1_96[10]}"
    "${MODE0_CPUS3_96[10]}"
)

VIDEO_CPU_MAP_96CORE_MODE1=(
    "${MODE1_CPUS0_96}"
    "${MODE1_CPUS2_96}"
    "${MODE1_CPUS1_96}"
    "${MODE1_CPUS3_96}"
)

VIDEO_GPU_MAP_HB4_128CORE=(
    "${GPUS[0]}"
    "${GPUS[1]}"
    "${GPUS[2]}"
    "${GPUS[3]}"
)

VIDEO_GPU_MAP_HB8_128CORE=(
    "${GPUS[0]}"
    "${GPUS[4]}"
    "${GPUS[1]}"
    "${GPUS[5]}"
    "${GPUS[2]}"
    "${GPUS[6]}"
    "${GPUS[3]}"
    "${GPUS[7]}"
)

VIDEO_GPU_MAP_HB16_128CORE=(
    "${GPUS[0]}"
    "${GPUS[8]}"
    "${GPUS[4]}"
    "${GPUS[12]}"
    "${GPUS[1]}"
    "${GPUS[9]}"
    "${GPUS[5]}"
    "${GPUS[13]}"
    "${GPUS[2]}"
    "${GPUS[10]}"
    "${GPUS[6]}"
    "${GPUS[14]}"
    "${GPUS[3]}"
    "${GPUS[11]}"
    "${GPUS[7]}"
    "${GPUS[15]}"
)

VIDEO_GPU_MAP_HB4_320CORE=${VIDEO_GPU_MAP_HB4_128CORE[*]}

VIDEO_GPU_MAP_HB8_320CORE=${VIDEO_GPU_MAP_HB8_128CORE[*]}

VIDEO_GPU_MAP_HB16_320CORE=${VIDEO_GPU_MAP_HB16_128CORE[*]}

VIDEO_GPU_MAP_HB24_320CORE=(
    "${GPUS[0]}"
    "${GPUS[12]}"
    "${GPUS[4]}"
    "${GPUS[16]}"
    "${GPUS[8]}"
    "${GPUS[20]}"
    "${GPUS[1]}"
    "${GPUS[13]}"
    "${GPUS[5]}"
    "${GPUS[17]}"
    "${GPUS[9]}"
    "${GPUS[21]}"
    "${GPUS[2]}"
    "${GPUS[14]}"
    "${GPUS[6]}"
    "${GPUS[18]}"
    "${GPUS[10]}"
    "${GPUS[22]}"
    "${GPUS[3]}"
    "${GPUS[7]}"
    "${GPUS[11]}"
    "${GPUS[15]}"
    "${GPUS[19]}"
    "${GPUS[23]}"
)

# 瀚博有四张卡在前置Riser，8张卡与numa的对应关系为：1/1/0/0/3/3/2/2
VIDEO_GPU_MAP_HB32_320CORE=(
    "${GPUS[8]}"
    "${GPUS[24]}"
    "${GPUS[0]}"
    "${GPUS[16]}"
    "${GPUS[12]}"
    "${GPUS[28]}"
    "${GPUS[4]}"
    "${GPUS[20]}"
    "${GPUS[9]}"
    "${GPUS[25]}"
    "${GPUS[1]}"
    "${GPUS[17]}"
    "${GPUS[13]}"
    "${GPUS[29]}"
    "${GPUS[5]}"
    "${GPUS[21]}"
    "${GPUS[10]}"
    "${GPUS[26]}"
    "${GPUS[2]}"
    "${GPUS[18]}"
    "${GPUS[14]}"
    "${GPUS[30]}"
    "${GPUS[6]}"
    "${GPUS[22]}"
    "${GPUS[11]}"
    "${GPUS[27]}"
    "${GPUS[3]}"
    "${GPUS[19]}"
    "${GPUS[15]}"
    "${GPUS[31]}"
    "${GPUS[7]}"
    "${GPUS[23]}"
)

# 10张卡与numa物理上的对应关系为：1/1/1/0/0/3/3/3/2/2
# 容器绑核对应关系：numa1上第3张卡的后2个节点和numa0绑定，numa3上第3张卡的后2个节点和numa2绑定，其余节点绑核和实际显卡所在numa一致
# 渲染节点循环顺序如下：
# numa0卡1          -> numa2卡1          -> numa1卡1          -> numa3卡1           ->
# numa0卡2          -> numa2卡2          -> numa1卡2          -> numa3卡2           ->
# numa1卡3后2个节点  -> numa3卡3后2个节点 -> numa1卡1          -> numa3卡1           ->
# numa0卡1          -> numa2卡1          -> numa1卡2          -> numa3卡2           ->
# numa0卡2          -> numa2卡2          -> numa1卡3前2个节点  -> numa3卡3前2个节点
VIDEO_GPU_MAP_HB40_320CORE=(
    "${GPUS[12]}"
    "${GPUS[32]}"
    "${GPUS[0]}"
    "${GPUS[20]}"
    "${GPUS[16]}"
    "${GPUS[36]}"
    "${GPUS[4]}"
    "${GPUS[24]}"
    "${GPUS[10]}"
    "${GPUS[30]}"
    "${GPUS[1]}"
    "${GPUS[21]}"
    "${GPUS[13]}"
    "${GPUS[33]}"
    "${GPUS[5]}"
    "${GPUS[25]}"
    "${GPUS[17]}"
    "${GPUS[37]}"
    "${GPUS[8]}"
    "${GPUS[28]}"
    "${GPUS[14]}"
    "${GPUS[34]}"
    "${GPUS[2]}"
    "${GPUS[22]}"
    "${GPUS[18]}"
    "${GPUS[38]}"
    "${GPUS[6]}"
    "${GPUS[26]}"
    "${GPUS[11]}"
    "${GPUS[31]}"
    "${GPUS[3]}"
    "${GPUS[23]}"
    "${GPUS[15]}"
    "${GPUS[35]}"
    "${GPUS[7]}"
    "${GPUS[27]}"
    "${GPUS[19]}"
    "${GPUS[39]}"
    "${GPUS[9]}"
    "${GPUS[29]}"
)

# 7260(128核) XD GPU 6张卡配置，每张卡4个设备节点，总共24个设备节点，循环使用
VIDEO_GPU_MAP_XD6_128CORE=(
    "${GPUS[0]}"
    "${GPUS[12]}"
    "${GPUS[4]}"
    "${GPUS[16]}"
    "${GPUS[8]}"
    "${GPUS[20]}"
    "${GPUS[1]}"
    "${GPUS[13]}"
    "${GPUS[5]}"
    "${GPUS[17]}"
    "${GPUS[9]}"
    "${GPUS[21]}"
    "${GPUS[2]}"
    "${GPUS[14]}"
    "${GPUS[6]}"
    "${GPUS[18]}"
    "${GPUS[10]}"
    "${GPUS[22]}"
    "${GPUS[3]}"
    "${GPUS[15]}"
    "${GPUS[7]}"
    "${GPUS[19]}"
    "${GPUS[11]}"
    "${GPUS[23]}"
)

# 7260(128核) XD VPU编码节点 6张卡配置，每张卡4个编码节点，2个解码节点（暂不使用），总共24个编码节点
VIDEO_VPU_MAP_XD6_128CORE=(
    "${VPUS[0]}"
    "${VPUS[18]}"
    "${VPUS[6]}"
    "${VPUS[24]}"
    "${VPUS[12]}"
    "${VPUS[30]}"
    "${VPUS[1]}"
    "${VPUS[19]}"
    "${VPUS[7]}"
    "${VPUS[25]}"
    "${VPUS[13]}"
    "${VPUS[31]}"
    "${VPUS[2]}"
    "${VPUS[20]}"
    "${VPUS[8]}"
    "${VPUS[26]}"
    "${VPUS[14]}"
    "${VPUS[32]}"
    "${VPUS[3]}"
    "${VPUS[21]}"
    "${VPUS[9]}"
    "${VPUS[27]}"
    "${VPUS[15]}"
    "${VPUS[33]}"
)

# 7260(128核) XD GPU 4张卡配置，每张卡4个设备节点，总共16个设备节点，循环使用
VIDEO_GPU_MAP_XD4_128CORE=(
    "${GPUS[0]}"
    "${GPUS[8]}"
    "${GPUS[4]}"
    "${GPUS[12]}"
    "${GPUS[1]}"
    "${GPUS[9]}"
    "${GPUS[5]}"
    "${GPUS[13]}"
    "${GPUS[2]}"
    "${GPUS[10]}"
    "${GPUS[6]}"
    "${GPUS[14]}"
    "${GPUS[3]}"
    "${GPUS[11]}"
    "${GPUS[7]}"
    "${GPUS[15]}"
)

# 7260(128核) XD VPU编码节点 4张卡配置，每张卡4个编码节点，2个解码节点（暂不使用），总共16个编码节点
VIDEO_VPU_MAP_XD4_128CORE=(
    "${VPUS[0]}"
    "${VPUS[12]}"
    "${VPUS[6]}"
    "${VPUS[18]}"
    "${VPUS[1]}"
    "${VPUS[13]}"
    "${VPUS[7]}"
    "${VPUS[19]}"
    "${VPUS[2]}"
    "${VPUS[14]}"
    "${VPUS[8]}"
    "${VPUS[20]}"
    "${VPUS[3]}"
    "${VPUS[15]}"
    "${VPUS[9]}"
    "${VPUS[21]}"
)

# 7260(128核) XD GPU 2张卡配置，每张卡4个设备节点，总共8个设备节点
VIDEO_GPU_MAP_XD2_128CORE=(
    "${GPUS[0]}"
    "${GPUS[4]}"
    "${GPUS[1]}"
    "${GPUS[5]}"
    "${GPUS[2]}"
    "${GPUS[6]}"
    "${GPUS[3]}"
    "${GPUS[7]}"
)

# 7260(128核) XD VPU编码节点 2张卡配置，每张卡4个编码节点，2个解码节点（暂不使用），总共8个编码节点
VIDEO_VPU_MAP_XD2_128CORE=(
    "${VPUS[0]}"
    "${VPUS[6]}"
    "${VPUS[1]}"
    "${VPUS[7]}"
    "${VPUS[2]}"
    "${VPUS[8]}"
    "${VPUS[3]}"
    "${VPUS[9]}"
)

# 7260(128核) XD GPU 1张卡配置，每张卡4个设备节点，总共4个设备节点
VIDEO_GPU_MAP_XD1_128CORE=(
    "${GPUS[0]}"
    "${GPUS[1]}"
    "${GPUS[2]}"
    "${GPUS[3]}"
)

# 7260(128核) XD VPU编码节点 1张卡配置，每张卡4个编码节点，2个解码节点（暂不使用），总共4个编码节点
VIDEO_VPU_MAP_XD1_128CORE=(
    "${VPUS[0]}"
    "${VPUS[1]}"
    "${VPUS[2]}"
    "${VPUS[3]}"
)

# 7260(128核) HANBO 2张卡配置，对应4个设备节点，循环使用
VIDEO_HANBO_MAP_HANBO2=(
    "${HANBO_ENCODERS[0]}"
    "${HANBO_ENCODERS[2]}"
    "${HANBO_ENCODERS[1]}"
    "${HANBO_ENCODERS[3]}"
)

# 7260(128核) HANBO 1张卡配置，对应2个设备节点，循环使用
VIDEO_HANBO_MAP_HANBO1=(
    "${HANBO_ENCODERS[0]}"
    "${HANBO_ENCODERS[1]}"
)

VIDEO_CPU_MAP_64CORE_MODE0=(
    "${MODE0_CPUS0[0]}"
    "${MODE0_CPUS1[0]}"
    "${MODE0_CPUS0[1]}"
    "${MODE0_CPUS1[1]}"
    "${MODE0_CPUS0[2]}"
    "${MODE0_CPUS1[2]}"
    "${MODE0_CPUS0[3]}"
    "${MODE0_CPUS1[3]}"
    "${MODE0_CPUS0[4]}"
    "${MODE0_CPUS1[4]}"
    "${MODE0_CPUS0[5]}"
    "${MODE0_CPUS1[5]}"
    "${MODE0_CPUS0[6]}"
    "${MODE0_CPUS1[6]}"
    "${MODE0_CPUS0[7]}"
    "${MODE0_CPUS1[7]}"
    "${MODE0_CPUS0[8]}"
    "${MODE0_CPUS1[8]}"
    "${MODE0_CPUS0[9]}"
    "${MODE0_CPUS1[9]}"
    "${MODE0_CPUS0[10]}"
    "${MODE0_CPUS1[10]}"
    "${MODE0_CPUS0[11]}"
    "${MODE0_CPUS1[11]}"
    "${MODE0_CPUS0[12]}"
    "${MODE0_CPUS1[12]}"
    "${MODE0_CPUS0[13]}"
    "${MODE0_CPUS1[13]}"
    "${MODE0_CPUS0[14]}"
    "${MODE0_CPUS1[14]}"
)

VIDEO_CPU_MAP_64CORE_MODE1=(
    "${MODE1_CPUS0}"
    "${MODE1_CPUS1}"
)

# 5220(64核) AMD GPU 1张卡配置，对应1个设备节点
VIDEO_GPU_MAP_64CORE=(
    "${GPUS[0]}"
)

VIDEO_VSYNC_OFFSET_MAP_64CORE=(
    "${VSYNC_OFFSET0}"
    "${VSYNC_OFFSET1}"
)

